layui.use(['form', 'layer', 'upload'], function () {
    var form = layui.form
        ,$ = layui.jquery
        ,upload = layui.upload;

    let ajJsManagerList, ajJsList;
    //渲染ajJsManager下拉框，购买版本肯定是最新版
    _post("/aj/AjJsManager.do?method=listWithLastestAjJs", {page:1, rows: IntegerMax})
        .then(response => {
            ajJsManagerList = response.data;
            _initSingleSelectItem({
                form: form,
                selector: "#ajJsManager"
                ,dataList: response.data
                ,key: "lid"
                ,value: "name"
            });
        });

    //监听ajJsManager下拉框选择
    form.on('select(ajJsManager)', function(data){
        let jsManagerLid = data.value;
        if(!jsManagerLid) return;

        for(let item of ajJsManagerList){
            if(jsManagerLid == item.lid){
                $("#h_jsManagerName").val(item.name);
                $("#h_jsLid").val(item.ajLid);
                $("#version").val(item.version);
                $("#jsPrice").val(item.price);
            }
        }
    });

    verifyExt(form);
    form.on('submit(*)', function (data) { //form校验成功才会执行下面的代码
        //获取本页面的data
        let dataJson = serializeObject($("#bofrom"));
        //将数据插入到父页面的table中
        let tableData = parent.table.cache["grid"];
        tableData.push(dataJson);
        parent.tableIns.reload({data: tableData});
        //关闭当前页面
        closeThisLayer();
        return false; //禁用form表单自带的提交
    });

});